/*******************************************************************************
        
        copyright:		Copyright (C) 2010. All Rights Reserved
        				
        license:		BSD style: $(LICENSE)
        		
        author(s): 		D implementation by Mike Reinhold and Phil DeMonaco
        				
*******************************************************************************/
module tango.util.cipher.pad.NoPadding;

import tango.util.cipher.Cipher;

/*******************************************************************************

		Implementation of a no padding scheme
		
		Remarks: It is not safe to use this padding scheme with any block cipher
		mode that requires exact block sizes. For example CTR, CFB, and OFB block
		modes allow any input length while ECB, CBC, and PCBC block modes require
		inputs that are block size aligned
				
*******************************************************************************/
class NoPadding : BlockCipherPadding {
	
	NoPadding dup() {
		return new NoPadding();
	}
	
	/***************************************************************************
	
			name
		
			Returns:
			the string name of the padding algorithm implemented
		
	***************************************************************************/
	string name() {
		return "No Padding";
	}
	
	/***************************************************************************
	
			allowsReordering
		
			Returns:
			if the padding scheme is compatible with block reordering schemes
		
	***************************************************************************/
	bool allowsReordering(){
		return false;
	}

	/***************************************************************************
	
			pad
			
			Params:
			len = the number of padding bytes to generate
			
			Returns:
			a single pad byte
			
	***************************************************************************/
	ubyte[] pad(uint len) {
		ubyte[] pad = new ubyte[1];		
		return pad[];
	}

	/***************************************************************************
	
			unpad
			
			Params:
			input_ = the input text to find padding bytes for
			
			Returns:
			the number of padding bytes
			
	***************************************************************************/
	uint unpad(void[] input_) {
		return 1u; // the number of pad bytes
	}
}